Skip to main content

Templates Overview

The Templates section provides practical examples of the BindAI workflow system. These templates demonstrate common workflow execution patterns, including sequential execution, conditional branching, loops, parallel execution, human-in-the-loop tasks, retry handling, timeout protection, and scheduled execution. Each template focuses on one workflow capability while showing how that capability fits into the BindAI workflow runtime.

Purpose

The workflow templates are designed to:
  • demonstrate workflow execution patterns
  • explain how workflow nodes interact
  • show how execution state is managed
  • demonstrate failure and recovery behavior
  • illustrate workflows that pause for human interaction
  • demonstrate scheduling and execution management
  • provide practical examples of workflow orchestration
The templates complement the workflow implementation and the detailed workflow documentation.

Workflow Template Set

The current workflow template documentation contains the following examples: These templates cover the main workflow-control and execution-management mechanisms documented in this section.

Basic Workflow

The workflow templates build on the same general execution model. A basic workflow follows a sequence of nodes:
The workflow executor processes the workflow’s nodes and determines which node should execute next. The basic workflow template provides the foundation for understanding the more advanced templates.

Conditional Execution

The condition template demonstrates branching based on workflow state. Conceptually:
Conditions allow a workflow to choose different execution paths. This is useful when later execution depends on values produced by previous nodes.

Loops

The loop template demonstrates intentional repetition within a workflow. Conceptually:
Loops are useful when workflow logic must repeat until a condition becomes false. A loop is different from retry handling:
  • Loop — intentional repetition as part of workflow logic.
  • Retry — repeated execution caused by a node execution failure.

Parallel Execution

The parallel template demonstrates multiple workflow branches that can execute independently. Conceptually:
Parallel execution is useful when independent operations can progress without waiting for each other. The workflow can then continue after the relevant parallel branches have completed.

Human Tasks

The human template demonstrates workflows that pause while waiting for human interaction. Conceptually:
A human task represents work that cannot be completed automatically by the workflow. Typical examples include:
  • Approvals
  • Reviews
  • Validation
  • Manual decisions
  • Human confirmation
Human-task execution should be treated differently from ordinary node execution because the workflow may remain waiting until an external action occurs.

Retry

The retry template demonstrates recovery from failed node execution. When a node raises an exception and a RetryPolicy is configured, the executor can attempt the node again. Conceptually:
The current retry policy supports configuration such as:
The current executor uses max_attempts to control the number of attempts. The configured delay_seconds and exponential_backoff values are not currently applied by the executor, so retries occur without an implemented delay/backoff mechanism. This distinction is important when using retry configuration in the current release.

Timeout

The timeout template demonstrates protection against workflows running beyond their configured execution limit. A TimeoutPolicy defines the maximum workflow duration. Conceptually:
The executor checks elapsed workflow time using the workflow’s recorded start time. If the configured limit has been exceeded, the workflow fails with:
Timeout detection occurs between node executions. It does not forcibly interrupt a node that is already running. Therefore, timeout protection should be understood as workflow-level deadline checking rather than thread or process termination.

Scheduling

The schedule template demonstrates time-based workflow scheduling. A WorkflowSchedule contains scheduling information including:
  • workflow_id
  • next_run
  • interval_seconds
  • enabled
The WorkflowScheduler provides operations for managing schedules, including:
The scheduler determines which registered schedules are due. It does not execute workflows itself. The surrounding application or execution service is responsible for starting the corresponding workflow when a schedule is due. Recurring schedules advance next_run using the configured interval. Scheduling should therefore be considered separate from workflow execution.

How the Templates Relate

The templates demonstrate different aspects of workflow behavior.
The first group primarily demonstrates workflow control flow. The later templates demonstrate human interaction, failure recovery, execution protection, and scheduling.

Control Flow vs Execution Management

The templates can also be grouped by responsibility. This distinction helps explain which part of the workflow system is responsible for each behavior.

Learning Path

A practical order for learning the workflow system is:
The basic template introduces normal execution first. Conditions, loops, and parallel execution then introduce increasingly complex control flow. Human tasks introduce workflows that may wait for external interaction. Retry introduces recovery from node failures. Timeout introduces workflow-level execution protection. Scheduling introduces time-based workflow coordination without directly executing workflows itself.

Templates and Implementation

The templates document behavior provided by the BindAI workflow system. Important implementation concepts include:
  • workflow definitions
  • workflow nodes
  • execution context
  • node execution
  • execution state
  • control-flow decisions
  • human tasks
  • retry policies
  • timeout policies
  • workflow scheduling
  • workflow events where supported
The templates should therefore be read together with the corresponding workflow and node documentation. The templates are examples and learning material; they should not be interpreted as additional runtime APIs.

Best Practices

When using the workflow templates:
  • Start with the basic workflow.
  • Understand normal node execution before studying advanced control flow.
  • Distinguish intentional loops from retries.
  • Treat human tasks as waiting for external interaction.
  • Use retry policies for recoverable node failures.
  • Use timeout policies to limit workflow execution duration.
  • Remember that timeout checks do not forcibly terminate a running node.
  • Keep scheduling separate from workflow execution.
  • Design recurring workflows so repeated execution is safe.
  • Test workflows with both successful and failure paths.
  • Use execution events and application-level observability where available when troubleshooting.

Current Implementation Notes

The current workflow implementation has several important boundaries.

Retry

RetryPolicy exposes configuration for attempts, delay, and exponential backoff. The executor currently uses the attempt limit but does not implement the configured delay or exponential backoff.

Timeout

Timeouts are checked between node executions. A running node is not forcibly terminated when the timeout is exceeded.

Scheduling

WorkflowScheduler manages schedule state and determines which schedules are due. It does not itself execute the workflow.

Human Tasks

Human-task execution can place workflow processing into a waiting state until the required human interaction is completed.

Persistence

The workflow templates should not be interpreted as providing a general durable workflow persistence system. Persistence and deployment behavior depend on the surrounding BindAI components and application architecture.

Template Scope

The templates are intentionally focused examples rather than production-ready application architectures. For production systems, applications should additionally consider:
  • Error handling
  • Input validation
  • Authentication and authorization
  • External-service failures
  • Idempotency
  • Logging
  • Observability
  • Resource limits
  • Security
  • Deployment strategy
The templates demonstrate workflow mechanics; they do not automatically provide these application-level guarantees.

Summary

The Templates section provides a progression of workflow examples covering the main execution patterns documented by BindAI. The template set progresses from:
Together, the templates provide practical examples of how BindAI workflows can execute sequentially, branch, repeat, run independent branches, wait for human interaction, recover from node failures, enforce execution deadlines, and coordinate scheduled execution.